<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>55社区</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <%--引入公共样式--%>
    <jsp:include page="common.jsp"></jsp:include>
    <script src="${ctx}/static/js/area.js"></script>
</head>
<body>
<header data-am-widget="header" class="am-header am-header-default sq-head ">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.back()" class="">
            <i class="am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="" class="">新增收货地址</a>
    </h1>
</header>
<div style="height: 49px;"></div>
<form id="addressForm" action="#" onsubmit="return false;" method="post">
    <ul class="address">
        <li>
            <span>收货人：</span>
            <input type="text" name="address_username" class="add-input"/>
        </li>
        <li>
            <span>手&nbsp;&nbsp;&nbsp;机：</span>
            <input type="text" name="address_phone" class="add-input"/>
        </li>
        <li>
            <span>省份：</span>
            <select name="address_province" id="province" class="add-input"></select>
        </li>
        <li>
            <span>城市：</span>
            <select name="address_city" id="city" class="add-input"></select>
        </li>
        <li>
            <span>区/县：</span>
            <select name="address_county" id="county" class="add-input"></select>
        </li>
        <li>
            <span>小&nbsp;&nbsp;&nbsp;区：</span>
            <%-- <a href="village.html">
                 <input type="text" class="add-input" disabled="disabled" placeholder="澳元大厦"/>
             </a>--%>
            <input type="text" class="add-input" name="address_house" placeholder="春城路1110号"/>
            <i class="am-icon-angle-right" style="float: right; margin-top: 5px;"></i>
        </li>
        <li>
            <span>地&nbsp;&nbsp;&nbsp;址：</span>
            <textarea class="add-select" name="address_detail" rows="" cols=""></textarea>
        </li>
    </ul>


    <input type="button" class="login-btn addressAdd-btn" value="确认提交">
</form>
<script type="text/javascript">_init_area();</script>


<script>
    $(function () {
        $('.addressAdd-btn').click(function () {
            //详细地址获取
            var address_detail = $("input[name='address_province']").val() + $("input[name='address_city']").val()
                + $("input[name='address_county']").val() + " " + $("input[name='address_house']").val();
            $("input[name='address_detail']").val(address_detail);
            var myData = $("#addressForm").serialize();
            $.post("${ctx}/address/addressAddSave.do", myData, function (data) {
                if (data.state == 0) {
                    console.info(data.msg);
                    window.location.href = "${ctx}/address/addressList.do";
                } else {
                    alert(data.msg);
                }
            });
        })
    })
</script>
</body>
</html>
